package com.jay.media.kit

import kotlin.random.Random

/**
 * @author xuzhou4
 * @email xuzhou4@iflytek.com
 * @date 2022/7/22
 */
object RandomUtils {

    fun random(until: Int, notValue: Int, maxCount: Int): Int {
        var count = 0
        var nextInt = Random.nextInt(until)
        while (nextInt == notValue && count++ < maxCount) {
            nextInt = Random.nextInt(until)
        }

        if (nextInt == notValue) {
            nextInt = (notValue + maxCount) / until
        }

        return nextInt
    }
}